package com.lenovo.smarttraffic.ui.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lenovo.smarttraffic.R;

import java.util.List;

/**
 * Created by Caleb.F
 * on 2019-11-25
 *  * at 23:31
 */
public class MyMetroRecyclerAdapter extends RecyclerView.Adapter<MyMetroRecyclerAdapter.MyViewHolder> {
    private  Context mContext;
    private  List<String> mlist;
    public MyMetroRecyclerAdapter(Context context, List<String> list) {
        mContext=context;
        mlist=list;
        
    }


    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new MyViewHolder(LayoutInflater.from(mContext).inflate(R.layout.recyclerview_metro_item,parent,false));
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        holder.mTvMetroSpot.setText(mlist.get(position));
    }

    @Override
    public int getItemCount() {
        return mlist.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder{
        TextView mTvMetroSpot;

        public MyViewHolder(View itemView) {
            super(itemView);
        mTvMetroSpot = itemView.findViewById(R.id.tv_metro_spot);
        }
    }
}
